
//  Created by Xuan Mai on 3/19/14.
//  Copyright (c) 2013 Xuan Mai. All rights reserved.


#ifndef SAFE_RELEASE
#define	SAFE_RELEASE(ptr)	{if(ptr!=nil){[ptr release];ptr=nil;}}
#endif

#ifndef SAFE_DELETE
#define SAFE_DELETE(p) {if( p != NULL ){ delete p; p = NULL; }}
#endif

#ifndef SAFE_DELETE_ARRAY
#define SAFE_DELETE_ARRAY(p) {if( p != NULL ){ delete [] p; p = NULL; }}
#endif

#ifndef SAFE_FREE
#define SAFE_FREE(p) {if( p != NULL ){ free(p); p = NULL; }}
#endif

#ifndef SAFE_CLOSE
#define	SAFE_CLOSE(file)	if(file!=NULL) {fclose(file);file=NULL;}
#endif

#ifndef SAFE_RELEASE_TIMER
#define	SAFE_RELEASE_TIMER(timer)	if(timer!=NULL) {[timer invalidate]; timer = nil;}
#endif


#define RemoveNull(field) ([[result objectForKey:field] isKindOfClass:[NSNull class]]) ? @"" : [result objectForKey:field];

#define IS_WIDESCREEN ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
#define IS_IPHONE ( [ [ [ UIDevice currentDevice ] model ] isEqualToString: @"iPhone" ] )
#define IS_IPOD   ( [ [ [ UIDevice currentDevice ] model ] isEqualToString: @"iPod touch" ] )
#define IS_IPHONE_5 ( IS_IPHONE && IS_WIDESCREEN )

#define INTERFACE_IS_PAD     ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
#define INTERFACE_IS_PHONE   ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)

#define strDocumentPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
#define strResourcePath [[NSBundle mainBundle] resourcePath]
#define folderImage @"Image"
#define ImageDirectory [NSString stringWithFormat:@"%@/%@",strDocumentPath,folderImage]


#define strDocumentPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
#define strResourcePath [[NSBundle mainBundle] resourcePath]
#define folderImage @"Image"
#define ImageDirectory [NSString stringWithFormat:@"%@/%@",strDocumentPath,folderImage]
#define initDelegate (AppDelegate *)[[UIApplication sharedApplication] delegate];
#define characterKeyInset @"1234567890"

#define FORMATDATE @"dd/M/yyyy HH:mm a"










